﻿using System;
using System.Windows;
using System.Windows.Controls;
using Rio.Framework.Pages.Enums;

namespace Rio.Framework.Pages.MenuOffice
{
    public partial class OfficePageApplicationButton : UserControl
    {
        public string Title { get; set; }
        public Uri Image { get; set; }
        public ApplicationName Application { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="OfficePageApplicationButton"/> class.
        /// </summary>
        public OfficePageApplicationButton()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Sets the application image.
        /// </summary>
        private void SetApplicationImage()
        {
            switch (Application)
            {
                case ApplicationName.RioSearch:
                    Image = new Uri("/Rio.Framework.Pages;component/Assets/Images/OfficePage/consultation.png", UriKind.Relative);
                    break;
                case ApplicationName.RioImport:
                    Image = new Uri("/Rio.Framework.Pages;component/Assets/Images/OfficePage/importation.png", UriKind.Relative);
                    break;
                case ApplicationName.RioFlow:
                    Image = new Uri("/Rio.Framework.Pages;component/Assets/Images/OfficePage/flow.png", UriKind.Relative);
                    break;
                case ApplicationName.RioManager:
                    Image = new Uri("/Rio.Framework.Pages;component/Assets/Images/OfficePage/manager.png", UriKind.Relative);
                    break;
                case ApplicationName.RioOffice:
                default:
                    break;
            }
        }

        /// <summary>
        /// Handles the Click event of the Button control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            switch (Application)
            {
                case ApplicationName.RioSearch:
                    Redirection.RioSearch();
                    break;
                case ApplicationName.RioImport:
                    Redirection.RioImport();
                    break;
                case ApplicationName.RioOffice:
                    Redirection.RioOffice();
                    break;
                case ApplicationName.RioFlow:
                    Redirection.RioFlow();
                    break;
                case ApplicationName.RioManager:
                    Redirection.RioManager();
                    break;
                default:
                    break;
            }
        }

        /// <summary>
        /// Handles the Loaded event of the userControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void userControl_Loaded(object sender, RoutedEventArgs e)
        {
            SetApplicationImage();
        }
    }
}
